#include <fcntl.h>
#include <stdio.h>

int main(int argc,char**argv)
{
	int fd;
	unsigned char key_vals[4];
	int count=0;/* 计数 */
	fd = open("/dev/buttons",O_RDWR);
	if(fd<0)
	{
		printf("can't open!\n");
	}
	while(1)
	{
		read(fd,key_vals,sizeof(key_vals));
		
		if(!key_vals[0] || !key_vals[1] || !key_vals[2] || !key_vals[3])/* 若有任意一个为0 有按键按下*/
		{
			printf("%d key pressed:%d %d %d %d\n\r",count++,key_vals[0],key_vals[1],key_vals[2],key_vals[3]);
		}
	}
	return 0;
}







































